//
//  MineSecondCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/8.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "MineSecondCell.h"

@implementation MineSecondCell

- (instancetype)init
{
    if (self = [super init]) {
        
//        NSArray *arr = @[@"商品",@"加油卡",@"话费",@"充值记录",@"旅游"];
        NSArray *arr = @[@"商品",@"加油卡",@"话费",@"充值记录"];
        for (NSInteger i = 0; i < 4; ++i) {
            
            CGFloat HIGH = HEIGHT/10;
            
            CGRect frame = CGRectMake(WIDTH/4*i,0,WIDTH/4, HIGH);
            
            UIView *menubackView = [[UIView alloc] initWithFrame:frame];
            menubackView.tag = 100+i;
            [self.contentView addSubview:menubackView];
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myOrderDidClick:)];
            [menubackView addGestureRecognizer:tap];
            
            UIImageView *imageView = [[UIImageView alloc] init];
            imageView.contentMode = UIViewContentModeCenter;
            imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"wodeOrder_%ld",i]];
            [menubackView addSubview:imageView];
            
            if (i == 4) {
                imageView.image = [UIImage imageNamed:@"lvyou"];
            }
            
            UILabel *titleLabel = [[UILabel alloc] init];
            titleLabel.font = [UIFont systemFontOfSize:13];
            titleLabel.textAlignment = NSTextAlignmentCenter;
            titleLabel.text = [NSString stringWithFormat:@"%@",arr[i]];
            titleLabel.textColor = [UIColor grayColor];
            [menubackView addSubview:titleLabel];
            
            
            [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.centerY.equalTo(menubackView.mas_centerY).with.offset(-10);
                make.width.mas_equalTo(WIDTH/10);
                make.height.mas_equalTo(WIDTH/10);
                make.centerX.equalTo(menubackView.mas_centerX);
            }];
            
            
            [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.centerX.equalTo(menubackView.mas_centerX);
                make.width.mas_equalTo(WIDTH/4);
                make.height.mas_equalTo(10);
                make.top.equalTo(imageView.mas_bottom).offset(5);
            }];
            
            
        }
    }
    return self;
}

- (void)myOrderDidClick:(UITapGestureRecognizer *)Recognizer
{
    if ([self.delegate respondsToSelector:@selector(mineSecondCellDidClickIndex:)]) {
        [self.delegate mineSecondCellDidClickIndex:Recognizer.view.tag];
    }
}

@end
